{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-10T06:05:18.688625Z",
     "start_time": "2025-09-10T06:05:18.684819Z"
    }
   },
   "source": [
    "# 列表\n",
    "l = [1,2,2, 'hello', 'world']\n",
    "l[3] = 'everyone'\n",
    "l.append(5)\n",
    "print(l)\n",
    "# -1索引代表最后一个\n",
    "print(l[-1])\n",
    "# 返回列表从1到2的子列表\n",
    "print(l[1:3])\n",
    "# 元组\n",
    "tup = ('jason', 22)\n",
    "# tup[0] = 'haha'\n",
    "new_tup = tup + (5,)\n",
    "print(new_tup)\n",
    "print(new_tup[-1])\n",
    "# list函数转换\n",
    "list((6,8,7,9))\n",
    "# tuple函数转换\n",
    "tuple([9,8,6])\n",
    "# 列表2出现的次数\n",
    "l.count(2)\n",
    "#列表2第一次出现的索引\n",
    "l.index(2)\n",
    "# 存储空间\n",
    "l.__sizeof__()\n",
    "new_tup.__sizeof__()\n",
    "# 存储的数量跟空间不必用元组,可变的用列表"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 2, 'everyone', 'world', 5]\n",
      "5\n",
      "[2, 2]\n",
      "('jason', 22, 5)\n",
      "5\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "59a7cebe1441d4eb"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
